#include "ThreadPool.hpp"
#include "Task.hpp"
#include <ctime>

int main()
{
    // ThreadPool<Task>* tp = new ThreadPool<Task>();
    // tp->Init();
    // tp->Start();
    srand(time(nullptr));
    int cnt = 10;
    while (cnt--)
    {
        int x = rand() % 10 + 1;
        usleep(100); // 降低x y 的重复率
        int y = rand() % 10 + 1;
        Task t(x, y);

        // std::cout << t.debug() << std::endl;
        LOG(INFO, "Main thread push a task: %s\n", t.debug().c_str());
        ThreadPool<Task>::getInstance()->PushTask(t);// 句柄操作
        std::cout << ThreadPool<Task>::getInstance() << std::endl;
        sleep(1);
    }
    
    // 句柄操作
    ThreadPool<Task>::getInstance()->Stop();
    sleep(2);
    return 0;
}